<?php

require_once './application/core/CoreBase.php';
require_once './application/entity/admin/version.php';

class versionAdm extends CoreBase
{

    private $_rn;
    private $_ch;
    private $_obj;

    public function getVersion()
    {
        $this->_ch = curl_init();
        curl_setopt($this->_ch, CURLOPT_URL, 'http://ad-network.eu/version.html');
        curl_setopt($this->_ch, CURLOPT_CONNECTTIMEOUT, 1);
        curl_setopt($this->_ch, CURLOPT_RETURNTRANSFER, true);
        $this->_rn = curl_exec($this->_ch);
        curl_close($this->_ch);
        $this->_obj = new version();
        $this->_obj->version = 'Version : ' . ADN_VERSION;
        $this->_obj->version .= '<br/><br/>';
        $this->_rn = substr($this->_rn, 0, -1);
        if ($this->_rn == ADN_VERSION || $this->_rn == false)
            $this->_obj->version .= ADMIN_BODY_VERSION_NO_UPDATE;
        else
        {
            $this->_obj->version .= ADMIN_BODY_VERSION_UPDATE_TXT . ' : ' . $this->_rn;
            $this->_obj->version .= '<br/><a href="http://ad-network.eu/web/index.php/produit.html?art=dl">' . ADMIN_BODY_VERSION_UPDATE_LINK . '</a>';
        }
        echo Zend_Json_Encoder::encode($this->_obj);
    }

}